package com.jial08.designpatterns.factory.simple;

import com.jial08.designpatterns.factory.simple.impl.Add;
import com.jial08.designpatterns.factory.simple.impl.Div;
import com.jial08.designpatterns.factory.simple.impl.Mul;
import com.jial08.designpatterns.factory.simple.impl.Sub;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>类描述：工厂类。</p>
 *
 * @author jl
 * @version v1.0.0.1。
 * @since JDK1.8。
 * <p>创建日期：2019/10/11 下午8:03。</p>
 */
public class OperationFactory {
	public static Operation createOperate(String operate) {
		if (StringUtils.isBlank(operate)) {
			return null;
		}
		switch (operate) {
			case "+":
				return new Add();
			case "-":
				return new Sub();
			case "*":
				return new Mul();
			case "/":
				return new Div();
			default:
				return null;
		}
	}
}
